package ex.util;

public class BinaryOperation {
	public static int[] add(int[] ar1, int[] ar2) {
		int[] output = new int[ar1.length + 1];
		int res = 0;
		for(int i=ar1.length; i>0; i--) {
			int sum = ar1[i-1] + ar2[i-1] + res;
			if(sum > 1) {
				output[i] = sum % 2;
				res = 1;
			}
			else {
				output[i] = sum;
				res = 0;
			}
		}
		output[0] = res;
		return output;
	}
}
